// BaseSurface.cpp : implementation file
//

#include "stdafx.h"
#include "kwclientcore.h"
#include "BaseSurface.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBaseSurface

CBaseSurface::CBaseSurface(CBasePanel * pPanel):
m_pPanel(pPanel)
{
}

CBaseSurface::~CBaseSurface()
{
}


BEGIN_MESSAGE_MAP(CBaseSurface, CWnd)
	//{{AFX_MSG_MAP(CBaseSurface)
	ON_WM_PAINT()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CBaseSurface message handlers

bool CBaseSurface::Create(const CString& strWindowName, CWnd * pParentWnd)
{
  return CWnd::Create(NULL, strWindowName, WS_CHILD, CRect(0, 0, 0, 0), pParentWnd, 0);
}

void CBaseSurface::PostNcDestroy() 
{
	// TODO: Add your specialized code here and/or call the base class
	delete this;

	CWnd::PostNcDestroy();
}

void CBaseSurface::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
  Paint(dc);

	// Do not call CWnd::OnPaint() for painting messages
}

BOOL CBaseSurface::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	//CBrush * pBrush = new CBrush(RGB(192, 192, 250));
  CBrush * pBrush = new CBrush(RGB(255, 255, 255));
  CBrush * pOldBrush = pDC->SelectObject(pBrush);
  CRect rect;
  pDC->GetClipBox(&rect);
  pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
  pDC->SelectObject(pOldBrush);
  delete pBrush;

	return CWnd::OnEraseBkgnd(pDC);
}

void CBaseSurface::UpdateDisplay()
{
  if (IsWindowVisible())
  {
    Invalidate();
    UpdateWindow();
  }
}
